package com.jinkeen.xiaxie.base

import android.util.Log

fun main(args: Array<String>) {
    val sum = { a: Int, b: Int -> a + b }(6, 8)
    log("$sum")
    var sum2 = { a: Int, b: Int -> a + b }
    log(sum2(2, 3).toString())
    var list = 1..20
    log(list.pickNum {
        it % 5 == 0
    }.toString())
}


fun IntRange.pickNum(function: (Int) -> Boolean): List<Int> {
    val resultList = mutableListOf<Int>()
    for (i in this) {
        if (function(i)) {
            resultList.add(i)
        }
    }
    return resultList
}


const val TAG = "whzLog"
fun log(string: String) = println(string)

fun d(vararg logs: String) {
    val stringBuffer = StringBuffer()
    logs.forEach {
        stringBuffer.append(it)
    }
    Log.d(TAG, stringBuffer.toString())
}